﻿#coding:utf-8
from django import forms
from tubish.web.models import *


class RegisterForm(forms.Form):
    username = forms.CharField(label='姓名')
    password = forms.CharField(label='密码',widget=forms.PasswordInput())
    email = forms.EmailField(label='电子邮件')
    def clean_username(self):
        username = self.cleaned_data['username']
        
        if not User.objects.filter(username__iexact=username.strip()):#保证用户名不含特殊字符
            return username
        raise forms.ValidationError("用户名重复请重新选择")
        
class LoginForm(forms.Form):
    username = forms.CharField(label='姓名')
    password = forms.CharField(label='密码',widget=forms.PasswordInput())
